Syntax of numerical constants

The syntax of written representation of numbers is described formally in section~#numbersyntax#637>.

A number may be written in binary, octal, decimal, or hex by the use of a radix prefix. The radix prefixes are <#638#> #b<#638#><#639#>b<#639#> (binary), <#640#>#o<#640#><#641#>o<#641#> (octal), <#642#> #d<#642#><#643#>d<#643#> (decimal), and <#644#>#x<#644#><#645#>x<#645#> (hex). With no radix prefix, a number is assumed to be expressed in decimal.

A numeric constant may be specified to be either <#2282#>exact<#2282#> or <#2283#>inexact<#2283#> by a prefix. The prefixes are <#648#>#e<#648#><#649#>e<#649#> for <#2284#>exact<#2284#>, and <#651#>#i<#651#><#652#>i<#652#> for <#2285#>inexact<#2285#>. An exactness prefix may appear before or after any radix prefix that is used. If the written representation of a number has no exactness prefix, the constant may be either <#2286#>inexact<#2286#> or <#2287#>exact<#2287#>. It is <#2288#>inexact<#2288#> if it contains a decimal point, an exponent, or a ``'' character in the place of a digit, otherwise it is <#2289#>exact<#2289#>.

In systems with <#2290#>inexact<#2290#> numbers of varying precisions we may want to specify the precision we want to use to represent a constant internally. For example, we may want a constant that has the value of π rounded to the single precision length, or we might want a long precision number that has the value 6/10. For this purpose, we may express a number with an exponent marker that indicates the precision of the <#2291#>inexact<#2291#> representation. The letters <#660#>s<#660#>, <#661#>f<#661#>, <#662#>d<#662#>, and <#663#>l<#663#> specify the use of <#664#>short<#664#>, <#665#>single<#665#>, <#666#>double<#666#>, and <#667#>long<#667#> precision, respectively. (When fewer than four internal <#2292#>inexact<#2292#> representations exist, the four size specifications are mapped onto those available. For example, an implementation with two internal representations may map short and single together and long and double together.) In addition, the exponent marker <#669#>e<#669#> specifies the default precision for the implementation. The default precision has at least as much precision as <#670#>double<#670#>, but implementations may wish to allow this default to be set by the user.


#scheme671#